<template>
    <fieldset>
        <legend>列表页</legend>
        <ul v-if="goods.length">
            <li v-for="(item, index) in goods" :key="item.id" @click="jump(index)">
                <!-- <router-link :to="`/detail/${item.productId}`">{{item.productName}}</router-link> -->
                {{ item.productName }}
            </li>
        </ul>
        <h3 v-else>疯狂加载中......</h3>
    </fieldset>
</template>
<script>
export default {
    //http://chst.vip:1234/api/getmoneyctrl
    data() {
        return {
            goods: []
        }
    },
    mounted() {
        fetch('http://chst.vip:1234/api/getmoneyctrl')
            .then(body => body.json())
            .then(res => {
                console.log(res);
                let { result: data } = res
                this.goods = data
            })
    },
    methods: {
        jump(index) {
            console.log(this.goods[index].productId);
            let productid=this.goods[index].productId
            this.$router.push("/detail/"+productid)
            // this.$router.push({path:"/detail",query:{name:"det"}})
            // this.$router.push(`/detail/${productid}`)
        }
    }
}
</script>